package str

func RepeatedStringMatch(a string, b string) int {

	lenA := len(a)
	lenB := len(b)

	times := lenB / lenA

	tempStr := ""
	for i := 0; i < times; i++ {
		tempStr += a
	}

	for i := 0; i <= 2; i++ {
		if ifContain(tempStr, b) {
			return times + i
		} else {
			tempStr += a
		}
	}

	return -1

}

// 判断A是否包含b
func ifContain(a string, b string) bool {

	lenA := len(a)
	lenB := len(b)
	for i := 0; i <= lenA-lenB; i++ {
		if a[i:len(b)+i] == b {
			return true
		}
	}

	return false
}
